home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
Float source
/
fInterpret
< prev
next >
Wrap
Text File
|
1994-06-24
|
2KB
|
73 lines
\ fInterpret -- Replaces INTERPRET; provides interpretation of floats
\ 5/11/85 ssg Version 1.0
\ 9/19/85 cbd Modified for floating point heap.
\ 8/16/86 cdn Replace setupFP with FPinit
\ 5/27.92 rfl moved fpmodel stuff from fval to here; need finterpret running
\ scans str255 for decimal
:code scan ( addr -- b)
move.l (sp),a0
adda.l a3,a0
clr.l d7
move.b (a0)+,d7
subq.w #1,d7
j1 cmpi.b #46,(a0)+
beq out
dbra d7,j1
clr.l d0
bra bye
out moveq.l #1,d0
bye move.l d0,(sp)
;code
( addr -- flt t OR f) \ Attempts to convert token at addr to a float.
: fnumber { addr -- flt t OR f }
addr scan IF addr atof: floati/o ELSE false THEN ;
\ Write a float into dictionary: analogous to , or c, .
\ ( flt -- )
\ : f, dup 2+ here 10 cmove 10 allot fdrop ;
( b flt -- ) \ Compiles an in-line float
: fLiteral state IF compile flit f, ELSE swap THEN ; immediate
( -- b) \ True means string at here is a float.
: fFind here fnumber dup
IF swap [compile] fLiteral THEN ;
( -- ) \ Adds ability to interpret floats to INTERPRET.
: fInterpret
BEGIN find
IF state <
IF cfa , ELSE cfa execute THEN
ELSE fFind not \ fFind returns true if float found.
IF here number dpl 1+
IF [compile] dliteral
ELSE drop [compile] literal
THEN
THEN
THEN ?stack ?dp
AGAIN ;
\ store this word in OBJINIT to start up with float enabled
: FPinit init: floatI/O init: fltMem ;
\ new error handler for use with floating point extensions
: cleanFloat clean2 init: fltMem ;
\ Install finterpret as the new INTERPRET.
: yerk>flt 'c finterpret -> interpret
'c cleanFloat -> abortVec ;
\ Install INTERPRET in nucleus, disabling floating-pt parsing
: yerk>int 0 -> interpret
'c yerk -> objInit
'c clean2 -> abortVec ;
yerk>flt
0. fvalue fpmodel
'code fpmodel -> fvalcode \ patch value in Args file